//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Policy Injection Application Block
//===============================================================================

using System.Windows.Forms;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.Design;
using EntLibContrib.PolicyInjection.CallHandlers.Configuration.Design.Properties;

namespace EntLibContrib.PolicyInjection.CallHandlers.Configuration.Design
{
	/// <summary>
	/// A <see cref="ConfigurationNode"/> that represents the configuration
	/// of an <see cref="CursorCallHandler"/> in the Configuration
	/// Console.
	/// </summary>
	public class CursorCallHandlerNode : CallHandlerNode
	{
		#region Fields
		private Cursor cursor;
		#endregion

		#region Properties
		/// <summary>
		/// Cursor to use.
		/// </summary>
		/// <value>Get or set Cursor.</value>
		[SRDescription("CursorDescription", typeof(Resources))]
		[SRCategory("CategoryGeneral", typeof(Resources))]
		public Cursor Cursor
		{
			get { return cursor; }
			set { cursor = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Create a new <see cref="CursorCallHandlerNode"/> with default settings.
		/// </summary>
		public CursorCallHandlerNode()
			: this(new CursorCallHandlerData(Resources.CursorCallHandlerNodeName))
		{
		}

		/// <summary>
		/// Create a new <see cref="CursorCallHandlerNode"/> with the given settings.
		/// </summary>
		/// <param name="callHandlerData">Configuration information to initialize the node with.</param>
		public CursorCallHandlerNode(CursorCallHandlerData callHandlerData)
			: base(callHandlerData)
		{
			cursor = callHandlerData.Cursor;
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Converts the information stored in the node and generate
		/// the corresponding configuration element to store in
		/// an <see cref="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.IConfigurationSource"/>.
		/// </summary>
		/// <returns>
		/// Newly created <see cref="CursorCallHandlerData"/> containing
		/// the configuration data from this node.
		/// </returns>
		public override CallHandlerData CreateCallHandlerData()
		{
			CursorCallHandlerData callHandlerData = new CursorCallHandlerData(Name);
			callHandlerData.Cursor = cursor;

			return callHandlerData;
		}
		#endregion
	}
}
